<template>
	<view class="container">
		<view class="refund-info-container" v-if="maList.length > 0">
			<view class="refund-info new-border" v-for="(item,index) in maList" :key="index">
				<view class="refund-info-item">
					<text class="refund-info-item-title">兑换码：</text>
					<text class="refund-info-item-content">{{item.ExchangeMA}}</text>
				</view>
				<view class="refund-info-item">
					<text class="refund-info-item-title">兑换码状态：</text>
					<text class="refund-info-item-content">{{item.MAUseStatusDesc}}</text>
				</view>
				<view v-if="item.Status == 10">
					<view  class="refund-info-item">
						<view class="raffle-btn" @click="gotoRaffle(item.Id)" >去抽奖</view>
					</view>
				</view>
				<view v-else>
					<view class="refund-info-item">
						<text class="refund-info-item-title">中奖情况：</text>
						<text class="refund-info-item-content">{{item.PrizeName}}</text>
					</view>
					<view  class="refund-info-item">
						<text class="refund-info-item-title">抽奖时间：</text>
						<text class="refund-info-item-content">{{item.RaffleTime}}</text>
					</view>
				</view>
			</view>
		</view>
		<view v-else class="no-content">暂无抽奖码</view>
	</view>
</template>

<script>
	import {isLogin,toLogin,successToShow,errorToShow} from '@/config/common.js'
	import {getAppExchangeCertificateList} from '@/constant/customer.js'
	export default {
		data() {
			return {
				maList:[],
				query_filter: {
					customerId: uni.getStorageSync('customerId'),
					pageIndex: 0,
					pageSize: 10,
				}
			}
		},
		onLoad() {
			if (isLogin()) {
				this.getMaList();
			} else {
				toLogin();
			}
		},
		onReachBottom() {
			this.query_filter.pageIndex++;
			this.getMaList()
		},
		onPullDownRefresh() {
			this.query_filter.pageIndex = 0;
			this.getMaList()
		},
		methods: {
			async getMaList() { //订单列表
				let res = await getAppExchangeCertificateList(this.query_filter);
				uni.stopPullDownRefresh()
				if (this.query_filter.pageIndex > 0) {
					for (let i = 0; i < res.Source.length; i++) {
						let obj = res.Source[i];
						this.maList.push(obj);
					}
				} else {
					this.maList = res.Source;
				}
			},
			gotoRaffle(maId) { //去抽奖
				uni.redirectTo({
					url:'../../../packagePages/raffle/index?Id=' + maId 
				})
			}
		}
	}
</script>
<style>
	@import url("../../../css/common.css");
</style>
<style scoped lang="scss">
	.container {
		background-color: $main-page-color;
		height: 100vh;
		// overflow-y: auto;
	}
	
	.refund-info-container {
		display: flex;
		flex-direction: column;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
		.refund-info {
			min-height: 120rpx;
			font-size: 28rpx;
			&-item {
				margin: 20rpx;
	
				&-content {
					color: #999;
				}
			}
		}
	}
	
	.no-content {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100vh;
		width: 100%;
	}
	

	@keyframes mymove {
		from {
			right: -200px;
		}
	
		to {
			right: 0;
		}
	}
	
	
	.raffle-btn {
		border: 2rpx solid #279146;
		background-color: #279146;
		color: #fff;
		padding: 10rpx 20rpx 10rpx 20rpx;
		border-radius: 10rpx;
		font-size: 28rpx;
		width: 120rpx;
		text-align: center;
		float: right;
		margin-right: 10rpx;
		margin-bottom: 10rpx;
	}
</style>
